package com.java46.struts2.orderdetails.dao;

import com.java46.struts2.base.util.HibernateUtils;
import org.hibernate.query.Query;

import java.util.List;

/**
 * @ClassName OrderDetailsDao
 * @Description 订单详情数据处理
 * @Author zuxia
 * @Date 2018/7/18 10:44
 * @Vcrsion 1.0
 **/
public class OrderDetailsDao {

    /**
    *@Author xiao
    *@Description //根据订单编号查询订单详情
    *@Date 10:58 2018/7/18
    *@Param [orderid]
    *@return java.util.List
    */
    public static List queryDetailsOrderid(int orderid){
        String hql="from TOrderdetailEntity where orderId=?1";
        Query query=HibernateUtils.getQuery(hql);
        query.setParameter(1,orderid);
        List list = query.list();
        return list;
    }

    /**
    *@Author xiao
    *@Description //根据订单编号删除订单详情
    *@Date 15:00 2018/7/18
    *@Param [orderid]
    *@return void
    */
//    public static void deleteDetailsOrderid(int orderid){
//        Session session= HibernateUtils.getSession();
//        Transaction transaction =session.beginTransaction();
//        String hql="delete from TOrderdetailEntity where orderId=?1";
//        Query query=session.createQuery(hql);
//        query.setParameter(1,orderid);
//        query.executeUpdate();
//        transaction.commit();
//        session.close();
//    }

}
